#include<bits/stdc++.h>
using namespace std;
int a[200050];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int t=1;
    long long ans=0;
    int x=upper_bound(a+1,a+n+1,a[1])-a;
    int cnt=x-1;
    int y=upper_bound(a+1,a+n+1,a[x])-a;
    while(t){
        if(a[x]==a[n]){
            t=0;
        }
        if(y-x>=cnt){
            ans+=cnt;
            cnt=0;
        }else{
            ans+=y-x;
            cnt=cnt-y+x;
        }
        cnt+=y-x;
        x=y;
        y=upper_bound(a+1,a+n+1,a[x])-a;
    }
    cout<<n-ans;
    return 0;
}
